using System.Linq;
using System.Text.RegularExpressions;

namespace WebCrawler
{
    public class UrlParser
    {
        private const string UrlRegexp = @"(http|https)://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?";

        public static bool IsValidUrl(string url)
        {
            return Regex.IsMatch(url, UrlRegexp);
        }

        public static string[] MatchUrls(string text)
        {
            var matches = Regex.Matches(text, UrlRegexp);
            return matches.OfType<Match>().Where(m => m.Success).Select(m => m.Value).ToArray();
        }
    }
}